package output;
import java.util.Scanner;

import organization.Base;

public class AuditConsole extends Console {



	public AuditConsole() {
		consoleStr.add("Get all auditoriums numbers:");
		consoleStr.add("Get free auditoriums:");
		consoleStr.add("Add new auditorium:");
		consoleStr.add("Return to main menu.");
	}

	public void inputInConsole (){
		Scanner scan = new Scanner(System.in);
		int opt;
		while (true) {
			while (scan.hasNextLine()) {
				if (scan.hasNextInt()) {
					opt = scan.nextInt();
					if (1 <= opt & opt <= consoleStr.size()) {
						if (opt == 1) {
							Base.printAllAudit();
							getConsole();
							return;
						}
						if (opt == 2) {
							Base.printFreeAudit();
							getConsole();
							return;
						}
						if (opt == 3) {
							setNewAudit();
							getConsole();
							return;
						}
						if (opt == 4){
							return;
						}
					}
					System.out.println("Incorrect point.Please enter option:");
				}else {
					
					System.out.println("Input incorrect!Please enter option:");
					scan.next();
				}
			}
		}
	}

	private void setNewAudit() {

		int audNumber = 0;
		int audFloor = 0;
			Scanner scan = new Scanner(System.in);
			System.out.println("Please enter floor number:");
			if (scan.hasNextInt()) {
				audFloor = scan.nextInt();
				
			} else {
				System.out.println("Floor number must be numeric:");
				setNewAudit();
				return;
			}
			
			System.out.println("Please enter Auditorium number:");
			if (scan.hasNextInt()) {
				audNumber = scan.nextInt();
				
			} else {
				System.out.println("Auditorium number must be numeric:");
				setNewAudit();
				return;
			}
		if (audNumber != 0){
			Base.addAudit(audNumber, audFloor);
		}
		return;
	}

}
